package cn.edu.nju.ws.sview.util;

import cn.edu.nju.ws.sview.cache.FalconURIIDCache;
import cn.edu.nju.ws.sview.cache.URIIDCache;

/**
 * 集成了falcons数据和sview数据相互转化和利用的函数
 * @author Saisai Gong
 *
 */
public class SwitchSViewFalcons {
	/**
	 * 根据falcons uri id找到sview中的uri id，必要时在sview中新插入一个对应的uri
	 * @param falconURIID
	 * @return -1 if error happens
	 */
	public  static int getSViewURIIDByFalconID(int falconURIID){
		int resultID =-1;
		try {
			String falconURI = FalconURIIDCache.getInstance().getURI(falconURIID);
			int myID = URIIDCache.getInstance().getURIID(falconURI, true);
			resultID = myID;
		} catch (Throwable e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return resultID;
	}
	
    /**
     * 根据falcons uri 找到sview中的uri id，必要时在sview中新插入一个对应的uri
     * @param falconURI
     * @return
     */
	public static int getSViewURIIDByFalconURI(String falconURI){
		int resultID = -1;
		try {
			int falconURIID = FalconURIIDCache.getInstance().getURIID(falconURI);
			resultID = getSViewURIIDByFalconID(falconURIID);
		} catch (Throwable e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return resultID;
	}
}
